import { http } from '@/utils/http.ts'
import type { Category, Product } from '@/types'

// 获取商品分类列表
export const getProductCategoryListApi = () => {
  return http<Category[]>({
    url: '/user/category',
    method: 'GET',
  })
}

// 获取商品列表
export const getProductListApi = () => {
  return http<Product[]>({
    url: '/user/goods',
    method: 'GET',
  })
}

// 根据分类id获取商品
export const getProductListByCategoryIdApi = (categoryId: number) => {
  return http<Product[]>({
    url: '/user/goods/search',
    method: 'GET',
    data: {
      categoryId,
    },
  })
}
